import time
from selenium.webdriver.common.by import By

from base.page_base import BasePage


class OpenPage(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        self.activate_button = By.XPATH, '//*[@id="step3"]/div/div/div/div/a'
        self.name = By.XPATH, '//*[@id="safeName"]/div[2]/input'
        self.card = By.XPATH, '//*[@id="safeName"]/div[3]/input'
        self.submit = By.XPATH, '//*[@id="safeName"]/div[5]/div/input'
        self.opened = By.XPATH, '//*[@id="successForm"]/input'
        self.handle = (By.XPATH, '/html/body')

    def open(self, name, card):
        self.base_click(self.activate_button)
        self.base_input(self.name, name)
        self.base_input(self.card, card)
        self.base_click(self.submit)
        self.base_click(self.opened)

    def get_Open_success(self):
        result = self.get_handle(self.handle).text
        return result

    # def get_Open_result(self):
    #     import time
    #     time.sleep(2)
    #     result = self.fd_element(self.result).text
    #     return result
